<?php

/**
 * 支付方式配置logic
 */

namespace Member\Logic;

class MallPayLogic extends CommonLogic {
	
	/**
	 * 获取模板详细
	 * @param  integer $id 文档ID
	 * @return array       当前模型详细信息
	 */
	public function detail(){
		
		$map = array('uid'=>UID);
		
		$data = $this->where($map)->field(true)->find($id);
		if(!$data){
			$this->error = '获取详细信息出错！';
			return false;
		}
		
		$data['configs'] = serializeMysql($data['configs'],1);
		
		return $data;
		
	}
    
	//获取全部的模板信息
	public function allLists($map = array(),$field = array('id','title')){
	    $data = $this->where($map)->field($field)->order('id DESC')->select();
	    
	    return $data;
	    
	}
	
	
	/**
	 * (non-PHPdoc)
	 * @see \Member\Logic\BaseLogic::update()
	 */
	public function update($data){
		if(empty($data)){
			/* 获取文章数据 */
			$data = $this->create();
		}
		
		
		$data['uid'] = UID;
		
		if($data === false){
			return false;
		}
		
		$map = array(
		    'uid'=>UID,
		);
		//查询这条记录是否存在
		$info = $this->isexists($map);
		
		/* 添加或更新数据 */
		if(empty($info['id'])){//新增数据
			$data['id'] = null;
			$id = $this->add($data);
			if(!$id){
				$this->error = '新增详细内容失败！';
				return false;
			}
		} else { //更新数据
			$status = $this->where($map)->save($data);
			if(false === $status){
				$this->error = '更新详细内容失败！';
				return false;
			}
		}
		
		return true;
	}
	
	/**
	 * (non-PHPdoc)
	 * @see \Member\Logic\BaseLogic::autoSave()
	 */
	public function autoSave($id = 0){
		 
	}
}